import { http } from "@/utils/http";
/** 优惠券列表
 * @param
 * {"status":1,"page":1,"pageSize":20}
 */
export const couponList = (data?: any) => {
  return http.request("post", "/admin/coupon/coupon/list", { data });
};

/**
 * 获取优惠券详情
 */
export const couponInfo = (couponId: number) => {
  return http.request("post", "/admin/coupon/coupon/info", {
    data: { couponId }
  });
};
/**
 * 添加优惠券
 * 
 {
    "couponName": "required|string",
    "description": "string",
    "type": "required|integer",
    "value": "required|integer",
    "usageLimit": "required|integer",
    "perUserLimit": "required|integer",
    "validFrom": "date",
    "validTo": "date",
    "applicableProducts": "required|string",
    "status": "required|integer",
    "source": "required|string",
    "startTime": "date",
    "endTime": "date"
}
 */
export const addCoupon = (data?: any) => {
  return http.request("post", "/admin/coupon/coupon/add", { data });
};

/**
 * 更新设备
 * 
{
    "couponId": "required|integer",
    "couponName": "string",
    "description": "string",
    "type": "integer",
    "value": "integer",
    "usageLimit": "integer",
    "perUserLimit": "integer",
    "validFrom": "date",
    "validTo": "date",
    "applicableProducts": "string",
    "status": "integer",
    "source": "string",
    "startTime": "date",
    "endTime": "date"
}
 */
export const updateCoupon = (data?: any) => {
  return http.request("post", "/admin/coupon/coupon/set", { data });
};

/**
 * 
 * @param data {
    "couponId": 1,
    "data": [
        {
            "couponProductId": 1,
            "productType": "",
            "productId": "",
            "ruleType": "",
            "requiredType": "",
            "threshold": "",
            "maxCouponCount": "",
            "couponCount": "",
            "isActive": ""
        },
        {
            "productType": "",
            "productId": "",
            "ruleType": "",
            "requiredType": "",
            "threshold": "",
            "maxCouponCount": "",
            "couponCount": "",
            "isActive": ""
        }
    ]
}
 * @returns 
 */
export const handleCouponRule = (data?: any) => {
  return http.request("post", "/admin/coupon/product/handle", { data });
};

export const couponRuleList = (data?: any) => {
  return http.request("post", "/admin/coupon/product/list", { data });
};
